OpenLayers.Layer.Mapabc = OpenLayers.Class(
    OpenLayers.Layer.EventPane,
    OpenLayers.Layer.FixedZoomLevels, {
    MIN_ZOOM_LEVEL: 3,
    MAX_ZOOM_LEVEL: 17,
    RESOLUTIONS: [
		1.40625, 
        0.703125, 
        0.3515625, 
        0.17578125, 
        0.087890625, 
        0.0439453125,
        0.02197265625, 
        0.010986328125, 
        0.0054931640625, 
        0.00274658203125,
        0.001373291015625, 
        0.0006866455078125, 
        0.00034332275390625, 
        0.000171661376953125, 
        0.0000858306884765625, 
        0.00004291534423828125,
        0.00002145767211914062, 
        0.00001072883605957031,
        0.00000536441802978515
		],
    type: null,
    wrapDateLine: true,
    sphericalMercator: false,
    initialize: function(name, options) {
        OpenLayers.Layer.EventPane.prototype.initialize.apply(this, arguments);
        OpenLayers.Layer.FixedZoomLevels.prototype.initialize.apply(this, 
                                                                    arguments);
        if(this.sphericalMercator) {
            OpenLayers.Util.extend(this, OpenLayers.Layer.SphericalMercator);
            this.initMercatorParameters();
        }
    },
    loadMapObject:function() {

        var mabcDiv = OpenLayers.Util.createDiv(this.name); // create mapabc div
        
		var sz = this.map.getSize();
        mabcDiv.style.width = sz.w + "px";
        mabcDiv.style.height = sz.h + "px";
        this.div.appendChild(mabcDiv);

        try { 
            this.mapObject = new MMap(this.name);
        } 
		catch (e) { 
			alert('failed in creating mapObject!'); 
		}

        /*if (this.mapObject != null) {
            try {
                this.mapObject.LoadMap(null, null, this.type, true);
				alert('s');
                this.mapObject.AttachEvent("onmousedown", OpenLayers.Function.True);

            } 
			catch (e) { 
				alert('failed in attaching events!'); 
			}
				//this.mapObject.HideDashboard();
            if(typeof this.mapObject.SetAnimationEnabled == "function") {
                this.mapObject.SetAnimationEnabled(this.animationEnabled);
            }
        }
		*/
		this.mapObject.setCurrentMouseTool(PAN_WHEELZOOM); 
		this.mapObject.setContinuousZoom(true);
		this.mapObject.setDragEnabled(true);
		this.mapObject.setZoomEnabled(true);
    },

	// room function
    getOLZoomFromMapObjectZoom: function(moZoom) {
        var zoom = null;
        if (moZoom != null) {
            zoom = OpenLayers.Layer.FixedZoomLevels.prototype.getOLZoomFromMapObjectZoom.apply(this, [moZoom]);
            //zoom = 18 - zoom;
        }
        return zoom;
    },
    
    getMapObjectZoomFromOLZoom: function(olZoom) {
        var zoom = null; 
        if (olZoom != null) {
            zoom = OpenLayers.Layer.FixedZoomLevels.prototype.getMapObjectZoomFromOLZoom.apply(this, [olZoom]);
            //zoom = 18 - zoom;
        }
        return zoom;
    },
   
    setMapObjectCenter: function(center, zoom) {
		this.mapObject.setZoomAndCenter(zoom, center);
    },
   
    getMapObjectCenter: function() {
		return this.mapObject.getCenter();
    },
	
    dragPanMapObject: function(dX, dY) {
        alert('s');
		//this.mapObject.panTo(dX, dY);
		this.mapObject.panBy(new MSize(dX, dY), 10, SLIDING_LINEAR);
    },
    
    getMapObjectZoom: function() {
        return this.mapObject.getZoomLevel();
    },

    getMapObjectLonLatFromMapObjectPixel: function(moPixel) {
        return this.mapObject.fromContainerPixelToLngLat(moPixel);
    },
	
    getMapObjectPixelFromMapObjectLonLat: function(moLonLat) {
        return this.mapObject.fromLngLatToContainerPixel(moLonLat);
    },

    getLongitudeFromMapObjectLonLat: function(moLonLat) {
        return this.sphericalMercator ? 
            this.forwardMercator(moLonLat.lngX, moLonLat.latY).lon :
            moLonLat.lngX;
    },

    getLatitudeFromMapObjectLonLat: function(moLonLat) {
        return this.sphericalMercator ? 
            this.forwardMercator(moLonLat.lngX, moLonLat.latY).lat :
            moLonLat.latY;
    },
	
    getMapObjectLonLatFromLonLat: function(lon, lat) {
        var mLatLong;
        if(this.sphericalMercator) {
            var lonlat = this.inverseMercator(lon, lat);
            mLatLong = new MLngLat(lonlat.lat, lonlat.lon);
        } else {
            mLatLong = new MLngLat(lat, lon);
        }
        return mLatLong;
    },
	
    getXFromMapObjectPixel: function(moPixel) {
        return moPixel.x;
    },

    getYFromMapObjectPixel: function(moPixel) {
        return moPixel.y;
    },

    getMapObjectPixelFromXY: function(x, y) {
        return new MPoint(x, y);
    },
    
    getMapObjectSizeFromOLSize: function(olSize) {
        return new MSize(olSize.w, olSize.h);
    },
    CLASS_NAME: "OpenLayers.Layer.Mapabc"
});
